package com.play;


import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.filter.CorsFilter;

@RestController
@MapperScan({"com.play.mapper"})
@SpringBootApplication
public class PlayApplication {
	
//	APPID:c0ddc8b8
//
//	APISecret:YTlhMjgzZTA0MGYwNWIyODQ2NjM4MTk0
//
//	APIKey:9d6e26f653454801073cbaf53f2fa06f
//	

    public static void main(String[] args) {
        SpringApplication.run(PlayApplication.class, args);
    }
    
    /**
     * 跨域设置
     * 
     * @return
     */
    @Bean
    public CorsFilter corsFilter() {
      UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
      CorsConfiguration config = new CorsConfiguration();
      config.addAllowedOrigin("*");
      config.setAllowCredentials(false); // 当为true时，AllowedOrigin不能为*
      config.addAllowedHeader("*");
      config.addAllowedMethod("*");
      source.registerCorsConfiguration("/**", config);
      return new CorsFilter(source);
    }
    
}
